// schema扩展相关文档请参阅：https://uniapp.dcloud.net.cn/uniCloud/jql-schema-ext.html
var db = uniCloud.database();
module.exports = {
	trigger: {
		afterRead: async function({
			collection,
			operation,
			where,
			field,
			docId
		} = {}) {
			console.log(docId)

			// clientInfo.uniIdToken可以解出客户端用户信息，再进行判断是否应该加1。为了让示例简单清晰，此处省略相关逻辑
			if (field.includes('content')) {
				// 读取了content字段后view_count加1
				await db.collection('articles').doc(docId).update({
					view_count: db.command.inc(1)
				})
			}

		}
	}
}